$(function(){
    var dom = document.getElementById("mapshow");
    var myChart = echarts.init(dom);
    var app = {};
    option = null;
    option = {
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b}: {c} ({d}%)"
        },
        title: {
            "text": "总价",
            subtext: '180元',
            itemGap :10,
            left:'center',
            top:'20%',
            padding:[24,0],
            textStyle:{
                color:'black',
                align:'center'
            }

        },
        color:['#ffaa6c','#9ddf92', '#92c5ff ', '#fc9595'],
        legend: {
            selectedMode: false,
          /*  formatter: function(name) {
                var total = 0; //各科正确率总和
                var averagePercent; //综合正确率
                echartData.forEach(function(value, index, array) {
                    total += value.value;
                    console.log(total);
                });

                return '{total|' + total + '}';
            },
            data: [echartData[0].name],*/
            data: ['人工费','材料费','设计费','质检费'],
            orient: 'vertical',
            bottom: '10px',
            itemWidth:10,
            itemHeight:10,
            textStyle: {
                color: '#333',
                fontStyle: 'normal',
                fontWeight: 'normal',
                fontFamily: '微软雅黑',
                fontSize: 14,
            },
            formatter: function(name) {
                var oa = option.series[0].data;
                var num = 0;

                for (var i = 0; i < option.series[0].data.length; i++) {
                    num += parseFloat(oa[i].value);
                };
                for (var i = 0; i < option.series[0].data.length; i++) {
                    if (name == oa[i].name) {
                        return name + '  ' + (parseFloat(oa[i].value)).toFixed(2) + '元';
                    }
                }
            },


        },
        series: [{
            name: '占比',
            type: 'pie',
            radius: ['35%', '50%'],
            center: ['50%', '33%'],
            avoidLabelOverlap: false,
            label: {
                normal: {
                    show: false,
                    position: 'center',
                },
                emphasis: {
                    show: false,
                    formatter: function(param) {
                        return param.percent + '元';
                    },
                    textStyle: {
                        fontSize: '20',
                        fontWeight: 'bold'
                    }
                }
            },
            labelLine: {
                normal: {
                    show: false
                }
            },
            data: [
                {name:'人工费',value:30},
                {name:'材料费',value:20},
                {name:'设计费',value:40},
                {name:'质检费',value:40},
            ],
            /*data: echartData*/

        }]

    };

    if (option && typeof option === "object") {
        myChart.setOption(option, true);
    }
    window.addEventListener("resize",function(){
        myChart.resize();

    });
    myChart.setOption(option);




})